package com.gewu.bookeeping.View.ItemFragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gewu.bookeeping.MyDb.bean.ALiBeanOut;
import com.gewu.bookeeping.MyDb.bean.WeChtBeanOut;
import com.gewu.bookeeping.MyDb.dao.ALiDaoOutPerson;
import com.gewu.bookeeping.MyDb.dao.WeChtDaoOutPerson;
import com.gewu.bookeeping.R;
import com.gewu.bookeeping.View.adapter.oneItem3Adapter;

import java.util.List;

public class oneItem3Fragment extends Fragment {

    private RecyclerView viewById;
    private TextView viewById2;
    private oneItem3Adapter oneItem3Adapter;

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View inflate = LayoutInflater.from(container.getContext()).inflate(R.layout.activity_one_item3_fragment, container, false);
        initView(inflate);
        initShuJU();
        return inflate;
    }


    private void initShuJU() {

        WeChtDaoOutPerson weChtDaoOutPerson = new WeChtDaoOutPerson(getContext());
        List<WeChtBeanOut> quer = weChtDaoOutPerson.quer();

        ALiDaoOutPerson aLiDaoOutPerson = new ALiDaoOutPerson(getContext());
        List<ALiBeanOut> quer1 = aLiDaoOutPerson.quer();

        if (quer == null) {
            return;
        }

        oneItem3Adapter.setWeCharts(quer);

        if (quer1 == null) {
            return;
        }
        oneItem3Adapter.setAliLists(quer1);

        oneItem3Adapter.notifyDataSetChanged();
    }

    /**
     * 老样子
     *
     * @param inflate
     */
    private void initView(View inflate) {
        viewById = inflate.findViewById(R.id.recliview);
        viewById2 = inflate.findViewById(R.id.textView);
        viewById2.setSelected(true);
        oneItem3Adapter = new oneItem3Adapter();
        viewById.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        viewById.setAdapter(oneItem3Adapter);
    }


}